{extend name="../../base/view/common/base" /}
<!-- 主体 -->
{block name="body"}
<div class="p-3">
    <form class="layui-form gg-form-bar border-x border-t" lay-filter="barsearchform">

        <div class="layui-input-inline" style="width:240px;">
            <input type="text" name="keywords" placeholder="输入公司名称" class="layui-input" autocomplete="off"/>
        </div>
        <div class="layui-input-inline" style="width:150px;">
            <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform"><i
                    class="layui-icon layui-icon-search mr-1"></i>搜索
            </button>
            <button type="reset" class="layui-btn layui-btn-reset" lay-filter="reset">清空</button>
        </div>
    </form>
    <table class="layui-hide" id="test" lay-filter="test"></table>
</div>

<script type="text/html" id="toolbarDemo">
    <div class="layui-btn-container">
        <span class="layui-btn layui-btn-sm" title="添加公司自有" lay-event="add">+ 公司自有</span>
    </div>
</script>
{/block}
<!-- /主体 -->

<!-- 脚本 -->
{block name="script"}
<script>
    const moduleInit = ['tool'];
    // {
    //     field: 'check_status', title: '状态', align: 'center', width: 200, templet: function (d) {
    //     var html = '<span class="layui-btn layui-btn-xs layui-bg-' + d.check_status + '">' + d.status_name + '</span>';
    //     return html;
    // }
    // },
    function gouguInit() {
        var table = layui.table, tool = layui.tool, form = layui.form;
        layui.pageTable = table.render({
            elem: '#test',
            title: '项目列表',
            toolbar: '#toolbarDemo',
            defaultToolbar: ['filter', {title: '导出EXCEL', layEvent: 'LAYTABLE_EXCEL', icon: 'layui-icon-export'}],
            url: "/jobproject/busine/index", //数据接口
            cellMinWidth: 80,
            page: true, //开启分页
            limit: 20,
            cols: [
                [ //表头
                    {
                        field: 'id',
                        title: '编号',
                        align: 'center',
                        width: 80,
                        templet: function (d) {
                            return d.LAY_INDEX + 1
                        }
                    }, {
                    field: 'report_date',
                    title: '上报时间',
                    align: 'center',
                    width: 100
                }, {
                    field: 'gs_date',
                    title: '公示时间',
                    align: 'center',
                    width: 100
                }, {
                    field: 'license_name',
                    title: '公司名称',
                    width: 200
                }, {
                    field: 'is_zx',
                    title: '申报类型',
                    width: 160,
                },
                    {
                        field: 'cert_types',
                        title: '资质类型',
                        width: 200
                    }, {
                    field: 'projects',
                    title: '项目名称',
                    width: 200
                }, {
                    field: 'project_user_id', title: '人员分配', align: 'center', width: 150, templet: function (d) {
                        return d.project_user_name;
                    }
                }, {
                    field: 'report_status', title: '政府平台状态', align: 'center', width: 100, templet: function (d) {
                        if (d.report_status == 0) {
                            var html = '<span class="layui-btn layui-btn-xs" style="background-color: #8a8f97;">待上报</span>';
                        } else if (d.report_status == 1) {
                            var html = '<span class="layui-btn layui-btn-xs" style="background-color:#9B7536;">已上报</span>';
                        } else if (d.report_status == 2) {
                            var html = '<span class="layui-btn layui-btn-xs" style="background-color:#9B7536;">审核中</span>';
                        } else if (d.report_status == 3) {
                            var html = '<span class="layui-btn layui-btn-xs" style="background-color: #3C9CFF;">已公示</span>';
                        } else {
                            var html = '<span class="layui-btn layui-btn-xs" style="background-color: #8a8f97;">待上报</span>';
                        }
                        return html;
                    }
                },
                    {
                        field: 'report_status_name',
                        title: '公示提成审核状态',
                        align: 'center',
                        width: 200,
                        templet: function (d) {
                            var html = '<span class="black">待上报</span>';
                            if (d.check_status == 1) {
                                html = '<span class="blue">审核中</span>';
                            }
                            else if (d.check_status == 2) {
                                html = '<span class="green">审核通过</span>';
                            }
                            else if (d.check_status == 3) {
                                html = '<span class="red">审核不通过</span>';
                            }
                            else if (d.check_status == 4) {
                                html = '<span class="red">已撤销</span>';
                            }
                            else if (d.check_status == 5) {
                                html = '<span class="green">已开具</span>';
                            }
                            else if (d.check_status == 10) {
                                html = '<span class="yellow">已作废</span>';
                            }
                            return html;
                        }
                    },
                    {
                        field: 'right',
                        title: '操作',
                        align: 'center',
                        templet: function (d) {
                            var html = '<div class="layui-btn-group">';
                            var btn1 = '';
                            var btn2 = '';
                            var btn5 = '';
                            if (d.project_user_id == 0) {
                                btn1 = '<span class="layui-btn layui-btn-xs" lay-event="fenpei">人员分配</span>';
                            }
                            if (d.project_user_id != 0 && (d.check_status == 0||d.check_status == undefined)){
                                btn1 = '<span class="layui-btn layui-btn-xs" lay-event="fenpei">更换人员</span>';
                            }
                            if (d.check_status == 0||d.check_status == 3||d.check_status == undefined) {
                                btn2 = '<span class="layui-btn layui-btn-normal layui-btn-xs" lay-event="report_add">上报状态</span>';
                            }
                            var btn4 = '<span class="layui-btn layui-btn-warm layui-btn-xs" lay-event="view">查看</span>';

                            if (d.report_status == 3 && (d.check_status == 0||d.check_status == 3||d.check_status == undefined)) {
                                btn5 = '<span class="layui-btn layui-btn-normal layui-btn-xs" lay-event="project_report">提成上报</span>';
                            }
                            var btn6 = '';
                            if (3 > "{$uid}" && d.check_status == 0) {
                                var btn6 = '<span class="layui-btn layui-btn-xs" lay-event="project_edit">编辑</span>';
                            }

                            return html + btn1 + btn2 + btn4 + btn5 + btn6 + '</div>';


                        }
                    }
                ]
            ]
        });

        //表头工具栏事件
        table.on('toolbar(test)', function (obj) {

            if (obj.event === 'LAYTABLE_EXCEL') {
                var formSelect = form.val('barsearchform');
                formSelect.limit = 99999;
                $.ajax({
                    url: '/jobproject/busine/index',
                    data: formSelect,
                    success: function (res) {
                        table.exportFile('test', res.data, 'xls');
                    }
                });
                return;
            }
            if (obj.event === 'add') {
                tool.side('/jobproject/busine/project_add');
                return;
            }
        });

        //监听行工具事件
        table.on('tool(test)', function (obj) {
            var data = obj.data;
            if (obj.event === 'project_edit') {
                tool.side('/jobproject/busine/project_add?id=' + data.aid);
                return;
            }

            if (obj.event === 'report_add') {
                tool.side('/jobproject/busine/report_add?cert_id=' + data.aid);
                return;
            }
            if (obj.event === 'fenpei') {
                tool.side('/jobproject/busine/fenpei?cert_id=' + data.aid);
                return;
            }
            if (obj.event === 'project_report') {
                tool.side('/jobproject/busine/project_report?cert_id=' + data.aid);
                return;
            }
            if (obj.event === 'view') {
                tool.side('/jobproject/busine/view?id=' + data.aid);
                return;
            }
        });

        //选择合同性质
        var table_a;


        //选择母合同
        var table_b;


        //监听搜索提交
        form.on('submit(webform)', function (data) {
            layui.pageTable.reload({
                where: {
                    keywords: data.field.keywords,
                    cate_id: data.field.cate_id,
                    type: data.field.type,
                    check_status: data.field.check_status
                },
                page: {
                    curr: 1
                }
            });
            return false;
        });
    }
</script>
{/block}
<!-- /脚本 -->
